package handler

import (
	"food-stock-mgr/model"
	"github.com/gin-gonic/gin"
)

func List(c *gin.Context) {
	title := c.PostForm("title")
	content := c.PostForm("content")
	img := c.PostForm("img")
	video := model.Video{

		Title:   title,
		Content: content,
		Img:     img,
	}
	err := model.DB.Create(&video).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	} else {
		c.JSON(200, gin.H{
			"code": 200,
			"msg":  "添加成功",
		})
		return
	}
}
